import { reqAddressInfo, reqOrderInfo } from "@/api"

const state = {
    addressInfo:[],
    orderInfo:{}
}

const mutations = {
    GETUSERADDRESS(state, addressInfo) {
        // 不能实现
        state.addressInfo = addressInfo
    },
    GETORDERINFO(state, orderInfo) {
        state.orderInfo = orderInfo
    }
}

const actions = {
    // 获取用户地址信息
    async getUserAddress({ commit }) {
        let result = await reqAddressInfo()
        // console.log(result);
        if (result.code==200) {
            commit('GETUSERADDRESS', result.data)
        } 
    },
    // 获取用户商品信息
    async getOrderInfo({ commit }) {
        let result = await reqOrderInfo()
        // console.log(result)
        if (result.code == 200) {
            commit('GETORDERINFO',result.data)
        }
    }
}

const getters = {}

export default {
    state,
    mutations,
    actions,
    getters
}